#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <istream>
#include <string>
#include <vector>
using ll = int64_t;
#define printf
const ll p=2014;
std::string s;
ll n;
std::vector<std::vector<ll>> dp;

static inline ll dfs(const ll l,const ll r){
    struct S{
        const ll &l,&r,&dp;
        S(const ll&l,const ll&r,const ll&dp):l(l),r(r),dp(dp){
            printf("dfs l=%lld, r=%lld, START\n",l,r);
        }
        ~S(){
            printf("dfs l=%lld, r=%lld, ret=%lld\n",l,r,dp);
        }
    }raii(l,r,dp[l][r]);
    const ll nlen=r-l+1;
    if(l>r)return 0;
    if(dp[l][r])return dp[l][r];
    dp[l][r]=1;
    if(nlen<=2)return dp[l][r]=1;
    for(ll i=l+1;i<=r;i++){
        if(i-l==r-i+1)continue;
        const ll clen=std::min(i-l,r-i+1);
        if(i-l==1&&r-i+1==1)continue;
        for(ll j=0;j<clen;j++){
            if(s[l+j]!=s[i+j])goto nxt1;
        }
        dp[l][r]=((i-l>r-i+1?dfs(l, i-1):dfs(i, r))+dp[l][r])%p;
        nxt1:;
        for(ll j=0;j<clen;j++){
            if(s[i-1-j]!=s[r-j])goto nxt2;
        }
        dp[l][r]=((i-l>r-i+1?dfs(l, i-1):dfs(i, r))+dp[l][r])%p;
        nxt2:;
    }
    return dp[l][r];
}

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>s;
    n=s.size();
    s=' '+s;
    dp.resize(n+1,std::vector<ll>(n+1));
    std::cout<<(dfs(1,n)-1+p)%p<<"\n";
}